package xyz.lisys.spring.arsenal.advice;

import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@Slf4j
public class CustomAdvice implements MethodInterceptor {

    public void beforeAdvice() {
        log.info("beforeAdvice");
    }

    public void afterAdvice() {
        log.info("afterAdvice");
    }

    @Nullable
    @Override
    public Object invoke(@Nonnull MethodInvocation invocation) throws Throwable {
        log.info("Before advice: Executing before the method call");
        return invocation.proceed();
    }
}
